package com.roc.web.action.terminal;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class TermVerManageSearchCondition extends BaseSearchCondition{
	private String manufacturer;//厂商
	private String modelId;//型号
	private String versionId;//版本号
	private String minIssueTs;//发布日期
	private String maxIssueTs;//发布日期
	private String isValId;//是否有效（0有效,1无效）
	private String opId;//操作人ID

	

	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(manufacturer))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.MANUFACTURER", manufacturer.trim(),"=", false));
		}
		if(Constance.isNotEmpty(modelId))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.MODEL_ID", modelId.trim(),"=", false));
		}
		if(Constance.isNotEmpty(versionId))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.VERSION_ID", versionId.trim(),"=", false));
		}
		if(Constance.isNotEmpty(minIssueTs))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.ISSUE_TS", minIssueTs.trim(),">=", false));
		}
		if(Constance.isNotEmpty(maxIssueTs))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.ISSUE_TS", maxIssueTs.trim(),"<=", false));
		}
		if(Constance.isNotEmpty(isValId) && !isValId.equals("999"))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.IS_VALID", isValId.trim(),"=", false));
		}
		/*if(Constance.isNotEmpty(opId))
		{
			filedBeanList.add(new WhereHQLFieldBean("T.OP_ID", opId.trim(),"=", false));
		}*/
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT COUNT(1) FROM T_TERM_VER T LEFT JOIN t_operators O  ON T.OP_ID=O.ID  ")
		  .append(" where  1=1 ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT  T.ID, T.MANUFACTURER, T.MODEL_ID, T.VERSION_ID, T.ISSUE_TS, T.IS_VALID ,O.real_name FROM T_TERM_VER T LEFT JOIN t_operators O  ON T.OP_ID=O.ID ")
		  .append(" where  1=1 ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return " ORDER BY T.ISSUE_TS DESC ";
	}

	public String getManufacturer() {
		return manufacturer;
	}

	public void setManufacturer(String manufacturer) {
		this.manufacturer = manufacturer;
	}

	public String getModelId() {
		return modelId;
	}

	public void setModelId(String modelId) {
		this.modelId = modelId;
	}

	public String getVersionId() {
		return versionId;
	}

	public void setVersionId(String versionId) {
		this.versionId = versionId;
	}

	
	public String getMinIssueTs() {
		return minIssueTs;
	}

	public void setMinIssueTs(String minIssueTs) {
		this.minIssueTs = minIssueTs;
	}

	public String getMaxIssueTs() {
		return maxIssueTs;
	}

	public void setMaxIssueTs(String maxIssueTs) {
		this.maxIssueTs = maxIssueTs;
	}

	public String getIsValId() {
		return isValId;
	}

	public void setIsValId(String isValId) {
		this.isValId = isValId;
	}

	public String getOpId() {
		return opId;
	}

	public void setOpId(String opId) {
		this.opId = opId;
	}
}
